﻿using System;
using ZHDJ.JoinParty.BLL;
using FineUI;

namespace JoinParty.admin.FlowStep
{
    public partial class ThePartyBranchOpinion : PageBase
    {
        #region ViewPower

        /// <summary>
        /// 本页面的浏览权限，空字符串表示本页面不受权限控制
        /// </summary>
        public override string ViewPower
        {
            get
            {
                return "";
            }
        }

        #endregion
        #region Page_Load

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                BindData();
                LoadData();
            }
        }

        private void BindData()
        {
        }
        private void LoadData(string IsSave = "")
        {
            btnClose.OnClientClick = ActiveWindow.GetHideReference();
            if (!string.IsNullOrEmpty(this.CurrentStandID))
            {
                var oModel = DB.PartyJoinLinkExamples.Find(this.CurrentStandID);

                if (oModel != null)
                {
                    this.ckThePartyBranchOpinion.Text = oModel.Remark;
                }
            }
        }



        private void SaveData(bool isClose)
        {
            string Message = "";///接收处理流程反馈的消息主要判断当前步骤是否已审核过

            bool bResult = false;
            var oModel = DB.PartyJoinLinkExamples.Find(this.CurrentStandID);
            if (oModel != null)
            {
                oModel.Remark = this.ckThePartyBranchOpinion.Text;
                oModel.HandleUserID = this.CurrentUser.LoginID;
                oModel.HandleUserName = this.CurrentUser.UserName;
                oModel.HandleTime = DateTime.Now;
                oModel.Status = (int)Enum_FlowStanceStatus.通过;
                bResult = ProcesUtil.ApprovalProcesStep(oModel, out Message);
            }



            if (bResult)
            {
                Alert.Show("提交成功", String.Empty, ActiveWindow.GetHideReference());
            }
            else
            {
                if (!string.IsNullOrEmpty(Message))
                    Alert.Show(Message, String.Empty, ActiveWindow.GetHideReference());
            }
        }

        #endregion

        #region
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            this.SaveData(true);
            PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference());
        }
        #endregion
    }
}